package com.hkd.common.api.convert;

import com.hkd.common.api.enums.AreaType;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import java.util.Optional;

/**
 * @author HKD
 * @date 2022/9/11 14:51
 */
@Component
public class AreaTypeConvert implements Converter<Integer, AreaType> {
    @Override
    public AreaType convert(Integer source) {
        AreaType areaType = AreaType.search(source);
        return Optional.ofNullable(areaType).orElse(AreaType.AREA);
    }
}
